var express = require('express');
var musr = require('./users');
var mapi = require('./api')
var router = express.Router();

router.get('/', function (req, res, next) {
  let channel = req.query.channel || mapi.get_channel();
  if (musr.isLogined(req)) {
    res.render('index', { 
      "user": musr.getUser(req), 
      "ak": mapi.get_ak(), 
      "server": mapi.get_serverC(),
      "channel": channel,
      "token": musr.getSessionID(req)
    });
  } else {
    res.render('index2', { "user": musr.getUser(req) });
  }
});

module.exports = router;
